This example is for Wiring version 0027+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.
Stretch light by Karmen Franinovic
Controls an LED brightness by pulling a stretch sensor (rubbery ruler). The stretch sensor is made of conductive rubber, that changes resistance when it is streteched. The stretch sensor is connected to analog input pin 0 The LED is connected to the analog output (PWM) pin 37
Controls an LED brightness by pulling a stretch sensor (rubbery ruler). The stretch sensor is made of conductive rubber, that changes resistance when it is streteched. The stretch sensor is connected to analog input pin 0 The LED is connected to the analog output (PWM) pin 37

int sensorValue; void setup() { pinMode(37, OUTPUT); } void loop() { sensorValue = analogRead(0); // read analog input pin 0 sensorValue = (sensorValue - 400); // min value read from the stretch sensor was 400 sensorValue = constrain(sensorValue, 0, 1023); // constrain value analogWrite(37, sensorValue); // write value to PWM (analog) output 37 delay(50); // wait 50ms for next reading }